package com.example.springboot.mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
import com.example.springboot.pojo.Location;

@Mapper
public interface LocationMapper {

    @Select("select * from location where id=#{id}")
    Location findById(Integer id);

    @Insert("insert into location(name,photo,number,content,address,balance,type) " +
            "values(#{name},#{photo},#{number},#{content},#{address},#{balance},#{type})")
    void create(Location location);

    @Delete("delete from location where id=#{id}")
    void delete(Integer id);

    @Select("select * from location")
    List<Location> findAll();
    //根据输入的地区名来搜索
    @Select("select * from location where name like concat('%',#{name},'%')")
    List<Location> findByName(String name);

    @Update("update location set name=#{name},photo=#{photo},number=#{number},content=#{content},address=#{address},balance=#{balance},type=#{type} where id=#{id}")
    void update(Location location);

    //更新库存数量
    @Update("update location set balance=balance-1 where id=#{id}")
    void updateBalance(Integer id);



}
